package main

import (
	"fmt"
	"strconv"
)

//基本数据类型转string
func main()  {
	var num1 int = 99
	var num2 float64 = 23.4
	var b bool = true
	var char byte = 'a'

	var str string

	str = fmt.Sprintf("%d",num1)
	fmt.Printf("str type %T str=%q\n",str,str)

	str = fmt.Sprintf("%f",num2)
	fmt.Printf("str type %T str=%q\n",str,str)

	str = fmt.Sprintf("%t",b)
	fmt.Printf("str type %T str=%q\n",str,str)

	str = fmt.Sprintf("%c",char)
	fmt.Printf("str type %T str=%q\n",str,str)

	fmt.Println("-------------------------------------")

	var num3 int = 99
	var num4 float64 = 23.4
	var b2 bool = true

	str = strconv.FormatInt(int64(num3),10)
	fmt.Printf("str type %T str=%q\n",str,str)

	//f表示格式，10表示小数点后保留10位，64表示这个书是float64
	str = strconv.FormatFloat(num4,'f',10,64)
	fmt.Printf("str type %T str=%q\n",str,str)

	str = strconv.FormatBool(b2)
	fmt.Printf("str type %T str=%q\n",str,str)

	var num5 int64 = 234
	str = strconv.Itoa(int(num5))
	fmt.Printf("str type %T str=%q\n",str,str)
}

